<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>

    <link rel="stylesheet" href="./layui/css/layui.css">
    <script src="./layui/layui.js"></script>
    <script src="./layui/jquery.js"></script>
    <style>
        #form{
            width:800px;
            height:500px;
            position:absolute;
            top:50%;
            left:50%;
            margin-left:-400px;
            margin-top:-250px;
        }
    </style>
</head>
<body>
    <h1>汤唯，你哦好</h1>
    <button id="tangwei" class="layui-btn layui-btn-warm">汤唯</button>

    <div id="form">
        <h2 style="color: #008800;margin-left: 200px;" >注册</h2>
        <div class="layui-form-item">
            <label class="layui-form-label">账户名</label>
            <div class="layui-input-inline" style="width: 200px">
                <input type="text" name="userName" id="userName" required  lay-verify="required" placeholder="请输入账户名" autocomplete="off" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">辅助文字</div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">密码框</label>
            <div class="layui-input-inline"  style="width: 200px">
                <input type="password" name="password" id="password" required lay-verify="required" placeholder="请输入密码" autocomplete="off" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">辅助文字</div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">昵称</label>
            <div class="layui-input-inline" style="width: 200px">
                <input type="text" name="nickName" required id="nickName"  lay-verify="required" placeholder="请输入昵称" autocomplete="off" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">辅助文字</div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">简介</label>
            <div class="layui-input-inline" style="width: 200px">
                <input type="text" name="introduce" required id="introduce"  lay-verify="required" placeholder="请输入简介" autocomplete="off" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">辅助文字</div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button id="register" class="layui-btn layui-btn-warm" >立即注册</button>
                <button id=""       class="layui-btn layui-btn-normal" >去登录吧</button>
            </div>
        </div>
    </div>
</body>
</html>
    <script>
        /*layui.use(['layer','jquery'], function(){
            var img = "<img src='./layui/timg.jpg' id='img1' width='200px' height='300'>";
            var $ = layui.jquery,
            layer = layui.layer;

            $("#tangwei").click(function () {
                layer.msg('汤唯你好，我是唐伟');
                layer.tab({
                    //area: ['300px', '600px'],
                    tab: [{
                        title: '唐_伟',
                        content: img
                    }]
                });
            })
        });*/
       layui.use(['layer','jquery'], function(){
            var img = "<img src='./layui/timg.jpg' id='img1' width='200px' height='300'>";
            var $ = layui.jquery,
                layer = layui.layer;

            $("#register").click(function () {
                $tempArr = isEmpty();
                $.ajax({
                    url:'deal.php?model=register',
                    type:'post',
                    data:$tempArr,
                    dataType:'json',
                    async:false,
                    success : function (resp) {
                        if(resp.code == 1){
                            alert(resp.msg);
                            window.location.href = "{:url('admin/index/index')}";
                        }else{
                            alert(resp.msg);
                        }
                    }
                })
            })
        });

       function isEmpty() {
           /*var tempArr = ['userName','password','nickName','introduce'];
           var nameArr = ['账户名','密码','昵称','简介'];*/
           $userName = $("#userName").val();
           $password = $("#password").val();
           $nickName = $("#nickName").val();
           $introduce = $("#introduce").val();
           //console.log($userName,$password,$nickName,$introduce);
           if($userName == ""){
               return alert('账户名不能为空');
           }
           if($password == ""){
               return alert('密码不能为空');
           }
           if($nickName == ""){
               return alert('昵称不能为空');
           }
           if($introduce == ""){
               return alert('简介不能为空');
           }
           var dataObj = {
               'userName':$userName,
               'password':$password,
               'nickName':$nickName,
               'introduce':$introduce,
           };
            return dataObj;
       }


    </script>